<template>
  <div class="app-container">
    <!-- 订单流水搜索栏 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      v-show="showSearch"
      :inline="true"
    >
      <el-form-item label="订单编号" prop="orderNum">
        <el-input
          v-model="queryParams.orderNum"
          placeholder="请输入订单编号"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付流水号" prop="payNo">
          <el-input  v-model="queryParams.payNo" placeholder="请输入订单流水号" clearable size="small" @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="支付状态" prop="payStatus">
        <el-select
          v-model="queryParams.payStatus"
          placeholder="支付状态"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
<!-- 订单流水记录列表栏-->
    <el-table
      v-loading="loading"
      :data="flowlist"
    >
      <el-table-column label="id" prop="id"/>
      <el-table-column label="订单编号" prop="orderNum"/>
      <el-table-column label="支付流水号" prop="payNo"/>
      <el-table-column label="	支付金额" prop="payAmount"/>
      <el-table-column label="支付状态" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.payStatus == 0">失败</span>
          <span v-if="scope.row.payStatus == 1">成功</span>
        </template>
      </el-table-column>
      <el-table-column label="支付类型" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.payType == 0">微信</span>
          <span v-if="scope.row.payType == 1">支付宝</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createTime" align="center"/>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {flowList} from "@/api/order/flow";

export default {
  data() {
    return {
      //总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      //流水列表数据
      flowlist: [],
      // 状态数据字典
      statusOptions: [
          {
              dictLabel: '成功',
              dictValue: '0',
          },
          {
              dictLabel: '失败',
              dictValue: '1',
          }
      ],
      // 显示搜索条件
      showSearch: true,
    };
  },
    created() {
    this.getList();

  },
    methods: {
     /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
    /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
    /** 查询订单流水列表 */
        getList() {
            this.loading = true;
            flowList(this.queryParams).then((response) => {
                this.flowlist = response.rows;
                this.total = response.total;
                this.loading = false;
        });
        },
    }
};
</script>

<style>
</style>